<?php

namespace Service;

/**
 * 用户服务
 */
class User {
	private $_svrUserModel;

	/**
	 * 构造函数
	 * @param  void
	 * @return void
	 */
	public function __construct() {
		$this->_svrUserModel = \Lsf\Loader::model('SvrUser', TRUE);
	}

	/**
	 * 用户退出
	 * @param  int $uid 用户uid
	 * @param  array $token token
	 * @return mixed
	 */
	public function logout($uid, $token, $replace = '') {
		if (!empty($replace)) {
			$result = $this->_svrOauchService->loginOut($token);
		} else {
			$result = $this->_svrUserModel->studentLogout($uid, $token);
		}
		if (is_int($result) && $result < 0) {
			return $result;
		}
		if ($result['code'] != 0) {
			return -1;
		}
		return $result;
	}
}
